// const url = process.env.NODE_ENV === "production" ? window.location.href : 'https://ghmob.lingmao99.com/'
// const url = 'https://ghmob.lingmao99.com/'
// const url = 'https://ghmob.277sy.com/'
const url = window.location.href
console.log('测试地址', url);
const game = url.indexOf('277sy')
const cat = url.indexOf('lingmao99')

console.log(game, cat);

if (game >= 0) {
    //277游戏icon、title
    const iconUrl = './favicon.ico'
    const appleUrl = './version.png'
    addIconByLink(iconUrl)
    addAppleIcon(appleUrl)
    document.write('<meta name="apple-mobile-web-app-title" content="277速推助手">')
    document.write('<title>277速推助手</title>')
} else if (cat >= 0) {
    //灵猫游戏icon、title
    const iconUrl = './version_cat.png'
    const appleUrl = './version_cat.png'
    addIconByLink(iconUrl)
    addAppleIcon(appleUrl)
    document.write('<meta name="apple-mobile-web-app-title" content="灵猫速推助手">')
    document.write('<title>灵猫速推助手</title>')
}

export function appType() {
    const app_url = window.location.href
    const app_cat = app_url.indexOf('lingmao99')
        // console.log('调用了');
    if (app_cat > 0) {
        return 'cat'
    } else {
        return '277'
    }
}

export function appId() {
    if (cat >= 0) {
        return 401
    } else {
        return 1
    }
}

export function appName() {
    const appid = appId()
    if (appid === 401) {
        return '灵猫'
    } else {
        return '277'
    }
}


// icon图标
function addIconByLink(url) {
    var link = document.createElement("link");
    link.setAttribute("rel", "icon");
    link.setAttribute("href", url);
    var heads = document.getElementsByTagName("head");
    if (heads.length) {
        heads[0].appendChild(link);
    } else {
        document.documentElement.appendChild(link);
    }
}
// ios手机桌面生成图标
function addAppleIcon(url) {
    var link = document.createElement("link");
    link.setAttribute("rel", "apple-touch-icon");
    link.setAttribute("href", url);
    var heads = document.getElementsByTagName("head");
    if (heads.length) {
        heads[0].appendChild(link);
    } else {
        document.documentElement.appendChild(link);
    }
}